const { ipcRenderer } = require("electron");
window.ipcRenderer = ipcRenderer;

window.alwaysOnTop = () => {
  ipcRenderer.sendTo(window.senderId, "win", "alwaysOnTop");
  let data = window.getData()
  window.sendSaveData(data)
};

window.isAlwaysOnTop = () => {
  ipcRenderer.sendTo(window.senderId, "win", "isAlwaysOnTop");
};

window.getPosition = () => {
  ipcRenderer.sendTo(window.senderId, "win", "position");
};

window.moveDirection = (type, num) => {
  ipcRenderer.sendTo(window.senderId, "direction", {type, num});
}

window.sendSaveData = (data) => {
  ipcRenderer.sendTo(window.senderId, "saveData", data);
};

ipcRenderer.on("senderId", (event) => {
  window.senderId = event.senderId;
});

window.closeWin = () => {
  if(window.closeSettingWin){
    window.closeSettingWin()
  }
  ipcRenderer.sendTo(window.senderId, "win", "close");
};

// 向父页面传送数据
window.toParentPage = (data, info) => {
  ipcRenderer.sendTo(window.senderId, 'toParent', {data, ...info});
}




